package fragments;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.baseproject.BaseFragment;
import com.example.administrator.newxlmedical.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import constants.Constants;
import utils.ActivityUtil;


/**
 * Created by Administrator on 2018/5/8.
 */

public class HospitalInfoFragment extends BaseFragment {

    @BindView(R.id.hospital_info)
    TextView hospitalInfo;
    @BindView(R.id.hospital_departments)
    TextView hospitalDepartments;
    @BindView(R.id.hospital_address)
    TextView hospitalAddress;
    @BindView(R.id.hospipal_remarks)
    TextView hospipalRemarks;
    Unbinder unbinder;
    private SharedPreferences sharedPreferences;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_hospital_info, null);
        unbinder = ButterKnife.bind(this, view);
        sharedPreferences = ActivityUtil.getSharedPreferences(mContext);
        return view;
    }

    @Override
    protected void initView() {
        super.initView();
        String name = sharedPreferences.getString(Constants.HOSPITAL_NAME, "");
        String address = sharedPreferences.getString(Constants.HOSPITAL_ADDRESS, "");
        String departments = sharedPreferences.getString(Constants.HOSPITAL_DEPARTMENTS, "");
        String remarks = sharedPreferences.getString(Constants.HOSPITAL_REMARK, "");

        hospitalInfo.setText(name);
        hospitalAddress.setText(address);
        hospitalDepartments.setText(departments);
        if (TextUtils.isEmpty(remarks)) {
            hospipalRemarks.setText("无");
        }else {
            hospipalRemarks.setText(remarks);
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
